package question1;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetDemo {
    public static void main(String[] args) {
        TreeSet<Student> students = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()-o2.getAge()==0?o1.getName().compareTo(o2.getName()):o1.getAge()-o2.getAge();
            }
        });
        students.add(new Student("yyds","男",17));
        students.add(new Student("yy","女",16));
        students.add(new Student("san","男",15));
        students.forEach(st-> System.out.println(st));
    }
}
